package com.go.where.manager.action.go;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.go.where.manager.action.SuperAction;
import com.go.where.manager.common.Constants;
import com.go.where.manager.page.Pagination;
import com.go.where.manager.pojo.FamilySquareInfo;
import com.go.where.manager.service.FamilySquareService;

public class FamilySquareAction extends SuperAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4383195694100314090L;
	private static final Logger log = Logger
			.getLogger(FamilySquareAction.class);

	public Pagination<?> page;

	@Resource(name = "familySquareService")
	private FamilySquareService familySquareService;

	private FamilySquareInfo familySquareInfo;
	private FamilySquareInfo familySquareInfoQuery;

	private String id;

	/**
	 * 查询列表
	 * 
	 * @return
	 */
	public String list() {
		if (familySquareInfoQuery == null) {
			familySquareInfoQuery = new FamilySquareInfo();
			familySquareInfoQuery.setPageSize(Constants.INIT_PAGESIZE);
			familySquareInfoQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		try {
			familySquareInfoQuery.setIsDelete(Constants.NOT_DELETED);
			page = familySquareService.queryPage(familySquareInfoQuery);
		} catch (Exception e) {
			addActionError(e.getMessage());
			log.error("查询信息异常", e);
		}
		return LIST;
	}

	/**
	 * 假删除
	 * 
	 * @return
	 */
	public String falseDelete() {
		familySquareInfo = new FamilySquareInfo();
		familySquareInfo.setId(id);
		familySquareInfo.setIsDelete(Constants.DELETED);
		try {
			familySquareService.update(familySquareInfo);
			redirectionUrl = "family_square!list.htm";
			return SUCCESS;
		} catch (Exception e) {
			log.error("删除信息异常", e);
			addActionError("删除信息异常" + e);
			return this.list();
		}
	}

	public Pagination<?> getPage() {
		return page;
	}

	public void setPage(Pagination<?> page) {
		this.page = page;
	}

	public FamilySquareInfo getFamilySquareInfo() {
		return familySquareInfo;
	}

	public void setFamilySquareInfo(FamilySquareInfo familySquareInfo) {
		this.familySquareInfo = familySquareInfo;
	}

	public FamilySquareInfo getFamilySquareInfoQuery() {
		return familySquareInfoQuery;
	}

	public void setFamilySquareInfoQuery(FamilySquareInfo familySquareInfoQuery) {
		this.familySquareInfoQuery = familySquareInfoQuery;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
